import 'package:flutter/material.dart';

class WidgetsNote {
  Widget container() {
    return Container(
      alignment: Alignment.centerLeft,
      padding: EdgeInsets.all(0.0),
      //内间距
      margin: EdgeInsets.all(0.0),
      //外间距
      color: Colors.green,
      //背景颜色
      width: 100.0,
      //宽度
      height: 100.0,
      //高度
      decoration: BoxDecoration(
          border: Border.all(color: Colors.grey),//外边框
          color: Colors.white,
          borderRadius: BorderRadius.all(Radius.circular(10.0))),
      //圆角
      child: Text('Hello'),
    );
  }

  //阴影控件
  Widget drawer() {
    return Container(
      //Container圆角和Drawer阴影不能共存
      child: Drawer(
        elevation: 5.0, //阴影高度
        child: Text('Hello'),
      ),
    );
  }

  //MD控件,可以圆角,也可以阴影
  Widget material() {
    return Material(
      shape: StadiumBorder(
          side: BorderSide(
            color: Colors.green,
          )),//体育场形状
      borderRadius: BorderRadius.all(Radius.circular(5.0)),
      elevation: 1.0,
    );
  }

  //输入框
  //1.UnderlineInputBorder:只有一个下划线的输入框
  //2.OutlineInputBorder:圆角矩形边框的输入框,设置很大的时候变成体育场形状
  Widget circleTextField() {
    return TextField(
      maxLines: null,//自动换行
      decoration: InputDecoration(
        border: OutlineInputBorder(
            borderRadius: BorderRadius.all(Radius.circular(100.0))), //边框
        hintText: '请输入密码',
        contentPadding: EdgeInsets.only(
            left: 15.0, right: 15.0, top: 10.0, bottom: 10.0), //top和bottom决定高度,总高大概是45
      ),
      //focusNode: _focusNode,
    );
  }

  Widget text() {
    return Text(
      'Hello',
      style: TextStyle(fontSize: 14.0, color: Colors.black), //
    );
  }

  //去掉滑动到边缘回弹效果
  Widget keepScrollOffset() {
    return ListView(
      controller: ScrollController(keepScrollOffset: false),
    );
  }

  //权重控件
  Widget expanded() {
    return Expanded(
      flex: 1,
      child: Container(),
    );
  }

  //按键详解
  Widget button() {
    return RaisedButton(
      shape: BorderDirectional(),
      //去掉边缘的细微圆角
      color: Colors.white,
      //颜色
      splashColor: Colors.black38,
      //按下去涟漪颜色
      highlightColor: Colors.green,
      //按下去高亮颜色
      elevation: 0.0,
      //按键的高度
      highlightElevation: 0.0,
      //按下去之后的高度
      padding: EdgeInsets.all(0.0),
      //内间距
      onPressed: () {},
      //按键触发动作
      child: Container(),
    );
  }

  //网格控件
  Widget grid() {
    return GridView.count(
      crossAxisCount: 2,//有几列
      crossAxisSpacing: 10.0,//列与列间距
      mainAxisSpacing: 10.0,//行与行间距
      children: List.generate(
        5,
        (index) {
          Container();
        },
      ),
    );
  }

  //叠层控件
  Widget stack() {
    return Stack(
        alignment: Alignment.center,//居中叠层

    );
  }
}

class UtilsLearn {
  //延时处理
  delay() async {
    await Future.delayed(Duration(milliseconds: 50));
  }
}
